//
//  AdvertisementSectionController.swift
//  FeastBooking
//
//  Created by Imon on 2017/9/2.
//  Copyright © 2017年 Imon. All rights reserved.
//

import UIKit
import IGListKit

final class AdvertisementSectionController: ListSectionController {
    
    private var object: [String]?
    private let ratio: CGFloat = 9 / 16 //图片比例16：9
    
    override init() {
        super.init()
        inset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    }
    
    override func numberOfItems() -> Int {
        return 1
    }
    
    override func cellForItem(at index: Int) -> UICollectionViewCell {
        guard let cell = collectionContext?.dequeueReusableCell(of: AdvertisementCell.self, for: self, at: index) as? AdvertisementCell else {
            fatalError()
        }
        cell.urls = object
        return cell
    }
    
    override func sizeForItem(at index: Int) -> CGSize {
        let width = UIScreen.main.bounds.width
        return CGSize(width: width, height: width * ratio)
    }
    
    override func didUpdate(to object: Any) {
        self.object = object as? [String]
    }
}
